<script setup lang='ts'>
import { onMounted, ref } from 'vue';

    const aDom =    ref(null) //  1.建立ref对象
    const bDom =    ref(null) 
    onMounted(()=>{
        // console.log(aDom.value);
        if(aDom.value){
            const dom = aDom.value as HTMLAnchorElement
            dom.href="http://www.qq.com"
        }
        if(bDom.value){
            const dom = bDom.value as HTMLAnchorElement
            dom.onclick = () =>{
                alert("脱裤子放屁的写法")
            }
        }

       
    })
</script>
       
<template>
       <h1>获取a标签的dom对象</h1>
       <a ref="aDom" href="http://www.baidu.com">百度</a>
       <button  ref="bDom" >获取buttom的按钮</button>
</template>
       
<style scoped>
       
</style>

